import {
    reqbannerlist,
    reqbannerinfo,
} from "../../request/api.js"
const state = {
    info: {
        isshow: false,
        isadd: true
    },
    bannerlist: [],
    bannerinfo: [],
}
const getters = {
    info(state) {
        return state.info
    },
    bannerlist(state) {
        return state.bannerlist
    },
    bannerinfo(state) {
        return state.bannerinfo
    },
}
const mutations = {
    changeinfo(state, data) {
        state.info = data
    },
    bannerlist(state, data) {
        state.bannerlist = data
    },
    bannerinfo(state, data) {
        state.bannerinfo = data
    },

}
const actions = {
    bannerlist(context) {
        reqbannerlist().then(res => {
            context.commit("bannerlist", res.data.list)
        })
    },
    bannerinfo(context, data) {
        reqbannerinfo(data).then(res => {
            res.data.list.id = data.id
            context.commit("bannerinfo", res.data.list)
        })
    },
}
export default {
    state,
    getters,
    mutations,
    actions,
    namespaced: true
}